#ifndef __IMA_REQUEST_PROCESSOR_H__
#define __IMA_REQUEST_PROCESSOR_H__

#include "ImaDbInterface.h"
#include <vector>
#include <string>
#include <jansson.h>


using namespace std;

class ImaRequestProcessor {
	private:
		int processFeedbackRequest(json_t* pRoot, std::vector<std::string*>& messagesVector);
		int processRegistrationRequest(json_t* pRoot, std::vector<std::string*>& messagesVector, string& userId);
		int confirmRegistration(json_t* pRoot, const char* pEmailId);
		int processConfirmRegistrationRequest(json_t* pRoot, std::vector<std::string*>& messagesVector);
		int processUpdateUserDetailsRequest(json_t* pRoot, std::vector<std::string*>& messagesVector);
		int extractUserDetails(json_t* pDetailsObject, const char*& pImId, const char*& pName, const char*& pAddress, const char*& pCity, const char*& pState, const char*& pCountry, const char*& pZip, const char*& pPhone, const char*& pGender, const char*& pDob, std::vector<std::string*>& messagesVector);
		int processLoginRequest(json_t* pRoot, std::vector<std::string*>& messagesVector);
		int processAddInfoRequest(json_t* pRoot, std::vector<std::string*>& messagesVector, std::string& strInfoId);
		int processUpdateInfoRequest(json_t* pRoot, std::vector<std::string*>& messagesVector);
		int processDeleteInfoRequest(json_t* pRoot, std::vector<std::string*>& messagesVector);
		int extractRecipientInfo(const unsigned long& infoId, const json_t* pRecipientObject, unsigned long& recipientId, const char*& pRecipientName, const char*& pRecipientEmail, const char*& pRecipientPhone, const char*& pRecipientAddress, const char*& pRecipientRelationWithInfoOwner, std::vector<std::string*>& messagesVector); 
		int extractRecipientInfo(json_t* pDetailsObj, const char*& pRecipientName, const char*& pRecipientEmailId, const char*& pRecipientAddress, const char*& pRecipientAddr, const char*& recipientRelationship, std::vector<std::string*>& messagesVector); 
		int processAddInfoRecipientsRequest(json_t* pRoot, std::vector<std::string*>& messagesVector, std::string& strRecipientIds);
		int processUpdateRecipientRequest(json_t* pRoot, std::vector<std::string*>& messagesVector);
		int processAddRecipientRequest(json_t* pRoot, std::vector<std::string*>& messagesVector, std::string& strRecipientId);
		int processDeleteRecipientRequest(json_t* pRoot, std::vector<std::string*>& messagesVector);
		int processDeleteInfoRecipientRequest(json_t* pRoot, std::vector<std::string*>& messagesVector);
		int processUpdateLastAccessTimeRequest(json_t* pRoot, std::vector<std::string*>& messagesVector);
		int processChangePasswordRequest(json_t* pRoot, std::vector<std::string*>& messagesVector);
		int processForgotPasswordRequest(json_t* pRoot, std::vector<std::string*>& messagesVector);
		int processGetUserDetailsRequest(json_t* pRoot, std::vector<std::string*>& messageVector, char*& pResponse);
		int processGetRecipientsListRequest(json_t* pRoot, std::vector<std::string*>& messageVector);
		int processGetInfoListRequest(json_t* pRoot, std::vector<std::string*>& messageVector);
		int processFetchUserDataRequest(json_t* pRoot, std::vector<std::string*>& messagesVector, char*& pResponse);
		char* assembleUserDetailsResponse(int nAction, int nResult, int nStatusCode, std::vector<std::string*>& msgVector, const char* pEmailId, std::string& strName, std::string& strAddress, std::string& strCity, std::string& strState, std::string& strCountry, std::string& strZip, std::string& strPhone, std::string& strDob, std::string& strGender, std::string& strImId, std::string& strImService);
		char* assembleUserDataResponse(int nAction, int nResult, int nStatusCode, std::vector<std::string*>& msgVector, const char* pEmailId, std::string& strName, std::string& strAddress, std::string& strCity, std::string& strState, std::string& strCountry, std::string& strZip, std::string& strPhone, std::string& strDob, std::string& strGender, std::string& strImId, std::string& strImService, std::vector<RECIPIENT_DETAILS*>& recipientList, std::vector<INFO_DETAILS*>& infoList);

		char* assembleResponsePkt(int nAction, int nResult,
				int nStatusCode, std::vector<std::string*>& msgVector,
				string& id);
		int enqueueImIdForFriendRequest(const char* pEmailId);
	public:
		char* processRequest(const char* pJsonString);
		ImaRequestProcessor();
		ImaRequestProcessor(ImaRequestProcessor& imaReqProcObj);
		

};

#endif //__IMA_REQUEST_PROCESSOR_H__
